package daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import dao.nationalLineDao;
import pojo.Message;
import pojo.nationalLine;
import utils.DruidUtils;

public class nationalLineDaoImpl implements nationalLineDao{

	@Override
	public ArrayList<nationalLine> getNationalLine() {
		Connection conn = DruidUtils.getConnection();
		String sql = "select * from nationalLine";
		ArrayList<nationalLine> nlList = new ArrayList<nationalLine>();
		try {
			PreparedStatement pre = conn.prepareStatement(sql);
			
			ResultSet res = pre.executeQuery();
			while(res.next()) {
				nationalLine nl = new nationalLine();
				nl.setNlid(res.getInt("nlid"));
				nl.setYear(res.getInt("year"));
				nl.setMath(res.getInt("math"));
				nl.setEnglish(res.getInt("english"));
				nl.setPolitics(res.getInt("politics"));
				nl.setProfessionalCourse(res.getInt("professionalCourse"));
				nlList.add(nl);
			}
			res.close();
			pre.close();
			conn.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return nlList;
	}
	

}
